package Servlet.Test;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Creche.Admin.Administrateur;
import Creche.Bd.BD;


@SuppressWarnings("serial")
public class ShowAdmins extends HttpServlet {
	
	private ArrayList<Administrateur> admins;
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {
		
		response.setContentType("text/html");
		PrintWriter page = response.getWriter();
		
		String result="<strong>Admin en ligne</strong><br><br>";
		
		HttpSession session = request.getSession();
		Administrateur adm = (Administrateur)session.getAttribute("session");
		
		if (adm != null) result+= adm.getEmail();
		
		
		result+="<br><strong>Liste des admins</strong><br><br>";
			

		BD myBD = new BD();
		admins = myBD.getListAdmin();
		
		for (Administrateur a:admins)
		{
			result += a.getEmail() + "|" + a.getIdentifiant() + "|" + a.getMotDePasse() + "|" + a.getVille() + "<br>";
			
		}
		
		page.print(result);
		
	}

}
